/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.shapes;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.geom.*;

/**
 *
 * @author BIM1LA
 */
public class Shape_Vec  implements JShape{
    
    
    double x_rel,y_rel,dx_rel,dy_rel,offset;
    Dimension dim;
    //int x, y;
    GeneralPath gp = null;
    Color color = Color.white;
    Shape_FVE fve = null;
    double scale1 = 0.09;
    double scale2 = 350;
    
    public Shape_Vec(Dimension dim, double x_rel, double y_rel, double dx_rel, double dy_rel, Shape_FVE fve){
    
        this.offset = 0;
        this.x_rel = x_rel;
        this.y_rel = y_rel;
        this.dx_rel = dx_rel;
        this.dy_rel = dy_rel;
        this.dim = dim;
        this.fve = fve;
//        this.x = x;
//        this.y = y;
    
    }
    
    //public void updatedim(Dimension dim){this.dim = dim;}

    @Override
    public Rectangle getBounds() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Rectangle2D getBounds2D() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean contains(double x, double y) {

       return false;
        
    
    }

    @Override
    public boolean contains(Point2D p) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean intersects(double x, double y, double w, double h) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean intersects(Rectangle2D r) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean contains(double x, double y, double w, double h) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean contains(Rectangle2D r) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public PathIterator getPathIterator(AffineTransform at) {
        
        if(dx_rel == 0&& dx_rel == 0) return new GeneralPath().getPathIterator(at);
        
        gp = new GeneralPath();
        
        double x,dy,y,dx;
        
        x = (y_rel*dim.height)+offset;
        
        //dx = dy_rel*dim.height/40;
        dx = dy_rel*dim.height*scale1;

        y = (x_rel*dim.width)-offset;

        //dy = dx_rel*dim.width/40;
        dy = dx_rel*dim.width*scale1;

        
        double norm = Math.sqrt(dy*dy+dx*dx);
        double normx =  dx/norm;
        double normy = dy/norm;
        
        double crossx = -normy;
        double crossy = normx;
        
        gp.moveTo(y,x);
        gp.lineTo(y+dy,x+dx);
      
//        gp.lineTo(y+dy-dim.width*(normy+crossy)*fve.dy_rel,x+dx-dim.width*(normx+crossx)*fve.dx_rel);
//        gp.lineTo(y+dy-dim.width*(normy-crossy)*fve.dy_rel,x+dx-dim.width*(normx-crossx)*fve.dx_rel);

        
        
       gp.lineTo(y+dy-dim.width/scale2*(normy+crossy),x+dx-dim.width/scale2*(normx+crossx));
       gp.lineTo(y+dy-dim.width/scale2*(normy-crossy),x+dx-dim.width/scale2*(normx-crossx));
       gp.lineTo(y+dy,x+dx);
        
        
        
        //gp.lineTo(y+dx-dx*0.1,x+dy+dy*.1);
        
        return gp.getPathIterator(at);
    }

    @Override
    public PathIterator getPathIterator(AffineTransform at, double flatness) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    public Color getColor(){return color;}
    public void setColor(Color color){this.color=color;}
    
    public void setscale1(double scale){this.scale1 = scale;}
    public void setscale2(double scale){this.scale2 = scale;}
    
}
